import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import '../lib/install_plugin.dart';

void main() {
  TestWidgetsFlutterBinding.ensureInitialized();
  const MethodChannel('install_plugin').setMockMethodCallHandler((MethodCall methodCall) async {
    if (methodCall.method == 'installApk') {
      return {'isSuccess': true, 'errorMessage': ''};
    } else if (methodCall.method == 'goStore') {
      return {'isSuccess': true, 'errorMessage': ''};
    }
    return {'isSuccess': false, 'errorMessage': 'Method not implemented'};
  });

  test('installApk should call the method channel with correct parameters', () async {
    final String filePath = '/path/to/apk';
    final String ohosAppId = 'com.example.app';
    final result = await InstallPlugin.installApk(filePath, ohosAppId: ohosAppId);

    expect(result, isA<Map>());
    expect(result['isSuccess'], isTrue);
    expect(result['errorMessage'], isEmpty);
  });

  test('goStore should call the method channel with correct parameters', () async {
    final String filePath = 'https://example.com/appstore';
    final result = await InstallPlugin.goStore(filePath);

    expect(result, isA<Map>());
    expect(result['isSuccess'], isTrue);
    expect(result['errorMessage'], isEmpty);
  });
}